#include <iostream>
#include <string.h>
using namespace std;

int n; //十进制数 
int m; //转换的进制数
int stack[100];  //模拟栈
int top = 0;

//2013 10

void dfs(int num){
	
	if(num == 0) return;

	dfs(num/m);
	
	stack[top++] = num%m;
}


int main(){
	
	
	cin >>n >> m;
	
	dfs(n);

	for(int i = 0;i<top;i++){
		
		cout << stack[i];
	}
	return 0;
}